#include "stdafx.h"
#include "ToolCharType.h"

BOOL WCharToMByte(LPWSTR lpcwszStr, LPSTR& lpszStr)
{
	DWORD dwMinSize;
	return WCharToMByte(lpcwszStr, lpszStr, dwMinSize);
}

BOOL WCharToMByte(LPWSTR lpcwszStr, LPSTR& lpszStr, DWORD& dwMinSize)
{

	dwMinSize = WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,NULL,0,NULL,FALSE);
   
	lpszStr = new char[dwMinSize];
	if(lpszStr == NULL) {
		return FALSE;
	}
	else {
		WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,lpszStr,dwMinSize,NULL,FALSE);
		return TRUE;
	}
}